package c.x.jy.dao.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.math.BigDecimal;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

import lombok.Data;

/**
 * 会员订单表
 * 
 * @author amwhyh
 * @email xxx@xx.com
 * @date 2021-05-25 10:49:02
 */
@Data
@TableName("t_order")
public class OrderEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * ID
	 */
	@TableId
	private Long id;
	/**
	 * 订单编号
	 */
	private String orderNo;
	/**
	 * 商家ID
	 */
	private Long businessId;
	/**
	 * 会员ID
	 */
	private Long memberId;
	/**
	 * 订单状态 -1-已取消,-2-申请退款，-3-已退款，0-待付款,1-服务中，2-待评价，3-已完成
	 */
	private Integer status;
	/**
	 * 订单类型，1-咨询订单，2-闪测订单，3-提问订单，4-充值订单 5 会员认证订单
	 */
	private Integer serviceType;
	/**
	 * 大师ID
	 */
	private Long teacherId;
	/**
	 * 订单金额
	 */
	private BigDecimal totalAmount;
	
	/**
	 * 下单时间
	 */
	private Date createDate;
	

	@TableField(exist = false)
  	private BigDecimal actAmount;
	
	
	
	@TableField(exist = false)
	private	 OrderBillEntity orderBill;
	
	@TableField(exist = false)
	private List<OrderItemsEntity> itemlist;
	
    public BigDecimal getTotalAmount(){
     	if(itemlist!=null&&!itemlist.isEmpty()){
			BigDecimal total=BigDecimal.ZERO;
			for (OrderItemsEntity i : itemlist ) {
				total=	total.add(i.getOriginalPrice ());
			}
			return total;
		}
     	return totalAmount;
	 }
    
    public BigDecimal getActAmount(){
     	if(itemlist!=null&&!itemlist.isEmpty()){
			BigDecimal total=BigDecimal.ZERO;
			for (OrderItemsEntity i : itemlist ) {
				total=	total.add(i.getDiscountPrice());
			}
			return total;
		}
     	return actAmount;

	 }

	//支付时间
	private Date payDatetime;
    

}

